<!DOCTYPE html>
<style>
span.error {
	color: red;
}
</style>
<section class="content-header" style="padding: 3px 15px 0 15px;">
	<ol class="breadcrumb" id="nav_title"
		style="position:static;float:none;margin-bottom: 5px;">
		<li class="active"><i class="fa fa-home"
			style="font-size:20px;position:relative;top:2px;left:-3px;"></i>
			&nbsp; <a href="${rc.contextPath}/sys/index">首页</a></li>
		<li class="active">系统管理</li><li class="active">用户管理</li>
	</ol>
</section>
<div class="container-fluid">
	<div class="box box-primary">
		<div id="toolbar">
		<button type="button" class="btn"
				data-toggle="modal" data-target="#modal-edit" style="margin-left:0px;padding:3px 18px;background:#3399fe;color:#fff;">新增</button>
		<button id="edit" type="button" class="btn" style="margin-left:10px;padding:3px 18px;background:#3399fe;color:#fff;">编辑</button>
		<button id="deleteBtn" type="button" class="btn" style="margin-left:10px;padding:3px 18px;background:#f93a3a;color:#fff;">删除</button>
		</div>
		<div class="row">
			<table id="table" data-toggle="table" data-url="userlist"
				data-striped="true" data-toolbar="#toolbar" data-pagination="true"
				data-search="true" data-page-size="10">
				<thead>
					<tr>
						<th data-checkbox="true"></th>
						<th data-align="center" data-field="user_name"
							data-sortable="true">用户名</th>
						<th data-align="center" data-field="login_name"
							data-sortable="true">登录名</th>
						<th data-align="center" data-field="user_status"
							data-formatter="userstatus" data-sortable="true">状态</th>
						<th data-align="center" data-field="last_access_time"
							data-sortable="true">最后登录时间</th>
						<th data-align="center" data-field="create_date"
							data-sortable="true">创建时间</th>
					</tr>
				</thead>
			</table>
		</div>
	</div>
</div>
<!-- 新增的弹窗 -->
<div class="modal fade" id="modal-edit" aria-labelledby="modalEditLabel"
	aria-hidden="true" tabindex="-1">
	<div class="modal-dialog">
		<div class="modal-content">
			<form class="form-horizontal" id="addUserForm" action=""
				method="post">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-hidden="true">×</button>
					<h4 class="modal-title" id="modalEditLabel">新增用户</h4>
				</div>
				<div class="modal-body">
					<div class="form-group">
						<label class="col-sm-3 control-label">用户名</label>
						<div class="col-sm-9">
							<input name="uName" id="userName" maxlength="10" type="text" class="form-control" placeholder="用户名">
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label">登录名</label>
						<div class="col-sm-9">
							<input name="lName" id="loginName" type="text" maxlength="14" class="form-control" placeholder="登录名" style="ime-mode:disabled">
							<span id="message" style="color:red"></span>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label">密码</label>
						<div class="col-sm-9">
							<input name="lPwd" id="lopwd" type="password" class="form-control" placeholder="密码">
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label">角色</label>
						<div class="col-sm-9">
							<select id="productSelect" class="form-control" name="roleId">
								<option value="">--未选择--</option> 
								#foreach($role in $list)
								<option value="${role.roleId}">${role.roleName}</option>
								#end
							</select>
						</div>
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default closeBtn" data-dismiss="modal">关闭</button>
					<button id="saveBtn" type="submit" class="btn btn-primary">保存</button>
				</div>
			</form>
		</div>
	</div>
</div>

<div class="modal fade" id="modal-edit2"
	aria-labelledby="modalEditLabel" aria-hidden="true" tabindex="-1">
	<div class="modal-dialog">
		<div class="modal-content">
			<form class="form-horizontal" action="updateUser" method="post"
				id="updateUserForm">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-hidden="true">×</button>
					<h4 class="modal-title" id="modalEditLabel">编辑用户</h4>
				</div>
				<input name="userId" id="userId" type="hidden" class="form-control">
				<div class="modal-body">
					<div class="form-group">
						<label class="col-sm-3 control-label">用户名</label>
						<div class="col-sm-9">
							<input name="userName1" id="userName1" type="text" class="form-control" placeholder="用户名">
						</div>
						<input name="loginName1" id="loginName1" type="hidden">
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label">密码</label>
						<div class="col-sm-9">
							<input name="loginPassword1" type="password" class="form-control"
								placeholder="密码">
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label">角色</label>
						<div class="col-sm-9">
							<select id="editRoleId" class="form-control" name="roleId">
								<option value="">请选择</option> 
								#foreach($role in $list)
								<option value="${role.roleId}">${role.roleName}</option>
								#end
							</select>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label">状态</label>
						<div class="col-sm-9">
							<input name="userStatus" type="radio" value="1" id="yes">允许登录&nbsp;&nbsp;
							<input name="userStatus" type="radio" value="2" id="no">限制登录
						</div>
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default " data-dismiss="modal">关闭</button>
					<button id="saveBtn2" type="submit" class="btn btn-primary">保存</button>
				</div>
			</form>
		</div>
	</div>
</div>
<customScript> 
	<script type="text/javascript">
		//格式化操作列
		function userstatus(value, row, index) {
			var status = row.user_status;
			if(status == 1){
				return [
					"<span>允许登录</span>"
				].join('');	
			}
			if(status == 2){
				return [
					"<span>限制登录</span>"
				].join('');	
			}
			if(status == 3){
				return [
					"<span>禁止登录</span>"
				].join('');	
			}
		}
	</script> 
	<script type="text/javascript" src="${rc.contextPath}/views/admin/system/sysuser.js"></script> 
</customScript>